package algorithm.structure.tree.b;

public class BTreeNodeSYT {
	public static final int DEGREE = 2;

	private boolean isLeaf;
	private int n;
	private int[] keys;
	private BTreeNodeSYT[] children;
	public int getN() {
		return n;
	}
	public int getKey(int index) {
		return keys[index];
	}
	public BTreeNodeSYT getChildren(int index) {
		return children[index];
	}
	public void setChildren(int index,BTreeNodeSYT children) {
		this.children[index] = children;
	}
	public void setChildren(BTreeNodeSYT[] children) {
		this.children = children;
	}
	public void setKeys(int[] keys) {
		this.keys = keys;
	}
	public void setKeys(int index,int key) {
		this.keys[index] = key;
	}
	public void setN(int n) {
		this.n = n;
	}
	
	public boolean isLeaf() {
		return isLeaf;
	}
	public void setLeaf(boolean isLeaf) {
		this.isLeaf = isLeaf;
	}
	public int[] getKeys() {
		return keys;
	}
	public BTreeNodeSYT[] getChildren() {
		return children;
	}
	public static BTreeNodeSYT AllocateNode(){
		BTreeNodeSYT node = new BTreeNodeSYT();
		int[] keys = new int[2* DEGREE + 1];
		BTreeNodeSYT[] children = new BTreeNodeSYT[2* DEGREE + 2];
		node.setKeys(keys);
		node.setLeaf(true);
		node.setChildren(children);
		node.setN(0);
		return node;
	}
	
}
